package pers.cnzdy.tutorial.Chapter5_UI.Section8_Fragment;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import pers.cnzdy.tutorial.BuildConfig;
import pers.cnzdy.tutorial.R;

public class KPointDetailActivity extends AppCompatActivity {
    public static String TAG = "KPointDetailActivity";

    public static void startUp(Context context, String kpointCaption,
                                   String kpointDetail) {
        Intent intent = new Intent(context, KPointDetailActivity.class);
        intent.putExtra("kpoint_caption", kpointCaption);
        intent.putExtra("kpoint_detail", kpointDetail);

        if (BuildConfig.DEBUG && context == null)
            Log.d(TAG, "menu_context == null");

        context.startActivity(intent);

        Log.d(TAG, "显示知识点内容");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_kpoint_detail);

        String kpointCaption = getIntent().getStringExtra("kpoint_caption");
        String kpointDetail  = getIntent().getStringExtra("kpoint_detail");
        KPointDetailFragment kpointDetailFragment =
                (KPointDetailFragment) getSupportFragmentManager()
                .findFragmentById(R.id.kpoint_detail_fragment);

        kpointDetailFragment.refresh(kpointCaption, kpointDetail);
    }
}
